package com.caijin.web.controller.system.task;


import com.caijin.common.core.domain.Result;
import com.caijin.common.core.domain.entity.TaskContent;
import com.caijin.common.core.domain.entity.TaskInfo;
import com.caijin.system.service.ITaskContentService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 作业内容表 前端控制器
 * </p>
 *
 * @author Peas
 * @since 2021-05-28
 */
@RestController
@RequestMapping("/system/taskContent")
public class TaskContentController {

    @Autowired
    private ITaskContentService taskContentService;

    /**
     * 作业提交接口
     */
    @ApiOperation("作业提交接口")
    @RequestMapping(method = RequestMethod.POST,
            path = "/post")
    public Result postTask(@RequestBody TaskContent taskContent) {
        return taskContentService.postTaskContent(taskContent);
    }

    @ApiOperation("获取作业内容")
    @RequestMapping(method = RequestMethod.GET,
            path = "/get")
    public Result getTask(@RequestParam("sno") Long sno, @RequestParam("taskInfoId") Long taskInfoId) {
        return taskContentService.getTaskContent(sno, taskInfoId);
    }

    @ApiOperation("通过id获取作业内容")
    @RequestMapping(method = RequestMethod.GET,
            path = "/get_by_id")
    public Result getTaskById(@RequestParam("id") Long id) {
        return Result.ok().data("data", taskContentService.getById(id));
    }

    @ApiOperation("获取已经提交作业的学生列表")
    @RequestMapping(method = RequestMethod.GET,
            path = "/get/postTaskList")
    public Result getPostTaskList(@RequestParam("taskInfoId") Long taskInfoId) {
        return taskContentService.getPostTaskList(taskInfoId);
    }
}

